﻿<h1>Listing subjects</h1>
<div style="border: solid #456">
  <%= start_form_tag :action => 'search' %>
    <input type="text" name="search_cond" />
    <%= submit_tag 'search' %>
  <%= end_form_tag %>
</div>

<table>
  <tr>
    <th>编号</th>
    <th>名称</th>
    <th>一级科目</th>
  </tr>

<% for subject in @subjects %>
  <tr>
  <% for column in Subject.content_columns %>
    <td><%=h subject.send(column.name) %></td>
  <% end %>
    <td>
    <%=  subject.parent_id==0?"-":(Subject.find(subject.parent_id)).name  %>
     </td>
    <td><a href="#"
    onclick="opener.document.getElementById('line_item_subject_id').value=<%=subject.id%>;
     opener.document.getElementById('line_item_subject_no').value='<%=subject.no%>';
     opener.document.getElementById('line_item_subject_name').value='<%=subject.name%>';
    window.close();">
    select
    </a>
    </td>
    <td><%= link_to 'Show', :action => 'show', :id => subject %></td>
    <td><%= link_to 'Edit', :action => 'edit', :id => subject %></td>
    <td><%= link_to 'Destroy', { :action => 'destroy', :id => subject }, :confirm => 'Are you sure?', :post => true %></td>
  </tr>
<% end %>

</table>

<%= link_to 'Previous page', { :page => @subject_pages.current.previous } if @subject_pages.current.previous %>
<%= link_to 'Next page', { :page => @subject_pages.current.next } if @subject_pages.current.next %>

<br />

<%= link_to 'New subject', :action => 'new' %>
